import { defineStore } from 'pinia';
import { reactive } from 'vue';
import type { SkuItem } from '@/types/product';

interface State {
  skuInfoList: SkuItem[];
}

export const useSkuInfo = defineStore(
  'skuInfo',
  () => {
    const state = reactive<State>({
      skuInfoList: [],
    });

    // 设置sku列表
    function setSkuInfoList(value: State['skuInfoList']) {
      state.skuInfoList = value;
    }

    // 清空sku信息
    function clearSkuInfo() {
      state.skuInfoList = [];
    }

    return { state, setSkuInfoList, clearSkuInfo };
  },
  {
    persist: true,
  }
);
